package com.sq.util;

public class LongUtil {
    /**
     * 是否奇数
     */
    public static boolean isOdd(long num) {
        return (num & 1) == 1;
    }

    /**
     * 把字符串转换为long
     */
    public static long parseLong(String str) {
        if (str == null || str.length() == 0) {
            return 0L;
        }
        try {
            return Long.parseLong(str);
        } catch (Exception e) {
            return 0L;
        }
    }

    /**
     * 获取多少位数
     */
    public static int getNumLenght(long num) {
        if (num == 0) {
            return 1;
        }
        num = Math.abs(num);
        return (int) Math.log10(num) + 1;
    }
}
